#Learning classes, time to play around with this shit!

#Author: Sam Robertson
#Modified: 1/13/2012

require "./Parser.rb"
require "./Cruncher.rb"

class Calc_Input
  #This class creates the interface for our calculator.  It's big fun.
  #*****ATTRIBUTE: parser is a parser
  #*****ATTRIBUTE: cruncher crunches the numbers
  @@myParser = 0
  @@myCruncher = 0
  def initialize
    @@myParser = Parser.new()
    @@myCruncher = Cruncher.new()
  end
  #this is where the heavy lifting will happen:  parse, then calculate using the resulting tree
  def calculate(input)
    output = input
    #create the symbol tree, using the parser
    myTree = @@myParser.parse(input)
    #calculate the symbol tree, using the cruncher
    output = @@myCruncher.crunch(myTree)
    #return the output, as a string
    return output
  end
end